package message

import "zstackgo/pkg/header/errorcode"

const (
	API_EVENT = "API_EVENT"
)

var (
	// _ APIResponse = new(APIEvent)
	_ APIEvent = new(APIEventImpl)
	_ Event    = new(APIEventImpl)
)

type APIEvent interface {
	GetApiId() string
	IsSuccess() bool
	GetError() *errorcode.ErrorCode
	GetSubCategory() string
}

func NewAPIEventImpl(apiId string) *APIEventImpl {
	return &APIEventImpl{
		EventImpl: &EventImpl{
			MessageImpl: &MessageImpl{},
		},
		ApiId:   apiId,
		Success: true,
	}
}

type APIEventImpl struct {
	*EventImpl

	ApiId   string
	Success bool
	Error   *errorcode.ErrorCode
}

func (m *APIEventImpl) GetApiId() string {
	return m.ApiId
}

func (m *APIEventImpl) IsSuccess() bool {
	return m.Success
}

func (m *APIEventImpl) GetError() *errorcode.ErrorCode {
	return m.Error
}

func (m *APIEventImpl) GetSubCategory() string {
	return API_EVENT
}
